{include file="public/header" /}
<body class="gray-bg">
<div class="layui-fluid layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-body layui-form">
            <div class="layui-row layui-col-space10 layui-form-item ">
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="title" lay-verify="required" placeholder="文章标题">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">所属分类</label>
                    <div class="layui-input-block">
                        <select name="cate_id" lay-verify="required" lay-search="">
                            <option value="">请选择分类</option>
                            {if !empty($cate)}
                            {foreach name="cate" item="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/foreach}
                            {/if}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">关键字</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input " name="keyword" lay-verify="required" placeholder="文章关键字">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea name="remark" class="layui-textarea" lay-verify="required" placeholder="文章描述"></textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">单图片上传</label>
                    <input type="hidden" name="lay-img" id="lay-img">
                    <div class="layui-input-block">
                        <div id="lay-upload">上传图片</div>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            预览图：
                            <div class="layui-upload-list" id="lay-list">
                                <img class="layui-append-img" src="http://p73q8jzf0.bkt.clouddn.com/88b9d56b955bf005f447e54712c00bb2.jpg" onerror="this.src='/static/admin/images/no_img.jpg'">
                            </div>
                        </blockquote>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">单图片上传</label>
                    <input type="hidden" name="lay-img" id="lay-img1">
                    <div class="layui-input-block">
                        <div id="lay-upload1">上传图片</div>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            预览图：
                            <div class="layui-upload-list" id="lay-list1">
                            </div>
                        </blockquote>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">音频上传</label>
                    <input type="hidden" name="lay-music" id="lay-music">
                    <div class="layui-input-block">
                        <div id="lay-music-upload">上传音频</div>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            预览音频：
                            <div class="layui-upload-list" id="lay-music-list">
                                <div id="layui-audio" style="margin: 0 10px 10px 0;" ></div>
                            </div>
                        </blockquote>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">音频上传</label>
                    <input type="hidden" name="lay-music" id="lay-music1">
                    <div class="layui-input-block">
                        <div id="lay-music-upload1">上传音频</div>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            预览音频：
                            <div class="layui-upload-list" id="lay-music-list1">
                            </div>
                        </blockquote>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">上传视频</label>
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" id="lay-upload2">上传视频</button>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            预览视频：
                            <div class="layui-upload-list" id="lay-video-list">
                                <div style="display: block;width: 80%;height: auto;" id="video" data-url="http://img.ksbbs.com/asset/Mon_1703/05cacb4e02f9d9e.mp4" ></div>
                                <!--<span id="lay-msg" style="display: none;">-->
                                    <!--<div class="layui-progress layui-progress-big" lay-showpercent="true" lay-filter="lay-video">-->
                                        <!--<div class="layui-progress-bar" lay-percent="0%"></div>-->
                                    <!--</div>-->
                                    <!--<p>正在上传... <i class="layui-icon layui-icon-loading-1 layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i></p>-->
                                <!--</span>-->
                            </div>
                        </blockquote>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                    <label class="layui-form-label">多图片上传</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="del" id="del" value="">
                        <input type="hidden" id="hid" value="{$article.photo}">
                        <input type="hidden" name="photo" id="photo" value="{$article.photo}">
                        <div id="uploader" class="container">
                            <div class="queueList">
                                <div class="placeholder">
                                    <div id="filePicker"></div>
                                    <p>或将照片拖到这里</p>
                                </div>
                            </div>
                            <div class="statusBar" style="display:none;">
                                <div class="layui-progress layui-progress-big active" lay-showpercent="true">
                                    <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                    </div>
                                </div>
                                <div class="info"></div>
                                <div class="btns">
                                    <div id="goPicker" class="filePicker2"></div>
                                    <div class="uploadBtn">开始上传</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                    <label class="layui-form-label">多图片上传</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="del" id="del1" value="">
                        <input type="hidden" id="hid1" value="{$article.photo}">
                        <input type="hidden" name="photo" id="photo1" value="{$article.photo}">
                        <div id="uploader1" class="container">
                            <div class="queueList">
                                <div class="placeholder">
                                    <div id="filePicker1"></div>
                                    <p>或将照片拖到这里</p>
                                </div>
                            </div>
                            <div class="statusBar" style="display:none;">
                                <div class="layui-progress layui-progress-big active" lay-showpercent="true">
                                    <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                    </div>
                                </div>
                                <div class="info"></div>
                                <div class="btns">
                                    <div id="goPicker1" class="filePicker2"></div>
                                    <div class="uploadBtn">开始上传</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block" id="LAY_editor">
                        <p>{$article.content}</p>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">浏览量</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input " name="views" lay-verify="required" placeholder="文章浏览量">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">作者</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input " name="views" lay-verify="required" placeholder="文章作者">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">是否推荐</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_tui" value="1" title="是" checked>
                        <input type="radio" name="is_tui" value="2" title="否" >
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                        </button>
                        <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<!--<script type="text/javascript" src="__JS__/webupload/webuploader_update.js"></script>-->
<!--<script src="__JS__/we.js"></script>-->
<script>
    var n = wk.uploads({num:8,type:'png,jpg,gif',status:'update'})
    var l = wk.uploads({num:8,type:'png,jpg,gif',attr:1,status:'update'})
    function imgDel(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n);
    }
    function imgDel1(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,l);
    }
    var editor = wk.wang({elem:'#LAY_editor'});
    wk.lay_audio({elem:'#layui-audio',name:'b45030df9212d398a433610736ea8a51.mp3',src:'http://pi7sdygmd.bkt.clouddn.com/c38b5b14db26f742d782a09072a5edf2.mp3'});
    wk.uploadImg({size:2,type:'png',url:"{:url('Upload/upload')}"});
    wk.uploadImg({size:5,num:1,type:'jpg',url:"{:url('Upload/upload')}"});
    wk.uploadMusic({size:10,type:'mp3',url:"{:url('Upload/upload')}"});
    wk.uploadMusic({size:10,num:1,type:'mp3',url:"{:url('Upload/upload')}"});

    layui.config({
        base: '/src/' //静态资源所在路径
    }).extend({
         ckplayer: 'modules/ckplayer'
    }).use(['form','upload','ckplayer'], function() {
        var form = layui.form
            , upload = layui.upload
            , ckplayer = layui.ckplayer

        var vUrl = $('#video').data('url'),
            videoObject = {
                container: '#video',
                loop: false,
                autoplay: false,
                video: [
                    [vUrl, 'video/mp4']
                ]
            };
        var player = new ckplayer(videoObject);

        //普通图片上传
        // var uploadInst = upload.render({
        //     elem: '#lay-upload'
        //     ,url: '/admin/Upload/upload'
        //     ,accept: 'images' //上传文件类型images（图片）、file（所有文件）、video（视频）、audio（音频）
        //     ,acceptMime: '.png,.jpg' //筛选出指定文件类型
        //     ,exts: 'png|jpg' //允许上传的文件后缀,结合 accept 参数类设定
        //     ,auto: true //是否选完文件后自动上传
        //     ,size: 2*1024 //文件最大可允许上传的大小，单位 KB（0即不限制）
        //     ,field: 'file' //设定文件域的字段名
        //    ,progress : function(index, value) {
        //         element.progress('model' + index, value + '%');
        //     }
        //     ,before: function(obj){
        //         //预读本地文件示例，不支持ie8
        //         obj.preview(function(index, file, result){
        //             $('#lay-list').attr('src', result); //图片链接（base64）
        //         });
        //     }
        //     ,done: function(res){
        //         //上传成功
        //         if(res.code == 300){
        //             layer.msg('上传成功');
        //         }
        //     }
        //     ,error: function(){
        //         //重传
        //         var layMsg = $('#lay-msg');
        //         layMsg.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs lay-reload">重试</a>');
        //         layMsg.find('.lay-reload').on('click', function(){
        //             uploadInst.upload();
        //         });
        //     }
        // });
        form.verify({
            username:function(value,item){
                if(!/^[\S]{2,10}$/.test(value)){
                    return '名称必须2到10字符，且不能出现空格';
                }
                var checkResult = "";
                $.ajax({
                    url:"{:url('User/checkName')}",
                    type:'post',
                    data:"username="+value,
                    async: false,//必须同步
                    success:function(res){
                        if(res.code == 100){
                            checkResult = "该名称已存在";
                        }
                    }
                })
                return checkResult;
            },
            pass: [/^[\S]{6,12}$/,'密码必须6到12位，且不能出现空格'],
            // headCrop:[/^[\S]$/,'头像不能为空'],
            // headCrop:function(value,item){
            //     if(value == ""){
            //         return '头像不能为空';
            //     }
            // },
            realname:[/^[\S]{2,10}$/,'真实姓名必须2到10字符，且不能出现空格']

        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('userAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
                        wk.error(res.msg);
                        return false;
                    }
                }
            })
        });
    });
</script>
</body>
</html>